import { Configuration, App } from '@midwayjs/decorator';
import * as koa from '@midwayjs/koa';
import * as validate from '@midwayjs/validate';
import * as info from '@midwayjs/info';
import { join } from 'path';
import * as orm from '@midwayjs/typeorm';
import * as redis from '@midwayjs/redis';
import * as swagger from '@midwayjs/swagger';
import * as axios from '@midwayjs/axios';
import * as bull from '@midwayjs/bull';
// import { DefaultErrorFilter } from './filter/default.filter';
// import { NotFoundFilter } from './filter/notfound.filter';
import { ReportMiddleware  } from './middleware/report.middleware';
import * as casbin from '@midwayjs/casbin';

import * as jwt from '@midwayjs/jwt';
import { AdminMiddleware } from './middleware/adminiogin ';

@Configuration({
  imports: [
    koa,,
    casbin,
    validate,
    redis       ,
    axios,
    orm   ,   
    jwt,          
    bull,          
      swagger   ,

        // swagger文档 访问地址http://127.0.0.1:7001/swagger-ui/index.html#
      {

      component: info,
      enabledEnvironment: ['local'],
    },
  ],
  importConfigs: [join(__dirname, './config')],
})
export class ContainerLifeCycle {
  @App()
  app: koa.Application;

  async onReady() {
    // add middleware

    this.app.useMiddleware([ReportMiddleware , AdminMiddleware ]);

    // add filter
    // this.app.useFilter([NotFoundFilter, DefaultErrorFilter]);
  }
}


console.log("swagger文档 访问地址 http://127.0.0.1:7001/swagger-ui/index.html#");

